﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;

namespace Ue.Qcdz.Domain.Resources
{
    public class ResourceService
    {
        private static IResourceRepository _repository;
        public ResourceService()
        {
            ResourceService._repository = RepositoryFactory.GetRepository<IResourceRepository, Resource>();
        }
        public static Resource GetResource(object resourceKey)
        {
            return ResourceService._repository.FindBy(resourceKey);
        }
        public static IList<Resource> GetResources()
        {
            return ResourceService._repository.FindAll();
        }
        public static IDataResult<Resource> GetResources(IDataQuery dataQuery)
        {
            return ResourceService._repository.FindBy(dataQuery);
        }
        public static void Addpermission(Resource resource)
        {
            ResourceService._repository.Add(resource);
        }
        public static void DelePermision(Resource resource)
        {
            ResourceService._repository.Remove(resource);
        }

        public static void UpdatePermission(Resource resource)
        {
            ResourceService._repository[resource.Key] = resource;
        }
    }
}
